﻿namespace Syx.Webapi.AppCode.Services {
    public class CachedCookie {
        public string Name { get; set; }
        public string Value { get; set; }
        public CookieOptions Options { get; set; }
        public bool IsDeleted { get; set; }
    }
    public interface ICookieService {
        void Delete(string cookieName);
        T Get<T>(string cookieName, bool isBase64 = false) where T : class;
        T GetOrSet<T>(string cookieName, Func<T> setFunc, DateTimeOffset? expiry = null, bool isBase64 = false) where T : class;
        void Set<T>(string cookieName, T data, DateTimeOffset? expiry = null, bool base64Encode = false) where T : class;
        void WriteToResponse(HttpContext context);
    }
    public class CookieService : ICookieService {
        private readonly HttpContext _httpContext;
        private Dictionary<string, CachedCookie> _pendingCookies = null;
        public CookieService(IHttpContextAccessor httpContextAccessor) {
            _httpContext = httpContextAccessor.HttpContext;
            _pendingCookies = new Dictionary<string, CachedCookie>();
        }

        public void Delete(string cookieName) {
        }

        public T Get<T>(string cookieName, bool isBase64 = false) where T : class {
            throw new NotImplementedException();
        }

        public T GetOrSet<T>(string cookieName, Func<T> setFunc, DateTimeOffset? expiry = null, bool isBase64 = false) where T : class {
            throw new NotImplementedException();
        }

        public void Set<T>(string cookieName, T data, DateTimeOffset? expiry = null, bool base64Encode = false) where T : class {
        }

        public void WriteToResponse(HttpContext context) {
        }
    }
}
